Page({
  data: {
    currentGroup: 0,
    currentWordIndex: 0,
    wordGroups: [
      {
        groupName: '水果类',
        words: [
          {
            english: 'apple',
            phonetic: 'æpl',
            chinese: '苹果'
          },
          {
            english: 'banana',
            phonetic: 'bəˈnɑːnə',
            chinese: '香蕉'
          },
          {
            english: 'orange',
            phonetic: 'ˈɔrɪndʒ',
            chinese: '橙子'
          },
          {
            english: 'grape',
            phonetic: 'ɡreɪp',
            chinese: '葡萄'
          },
          {
            english: 'peach',
            phonetic: 'piːtʃ',
            chinese: '桃子'
          }
        ]
      },
      // 第二组
      {
        groupName: '动物类',
        words: [
          {
            english: 'cat',
            phonetic: 'kæt',
            chinese: '猫'
          },
          {
            english: 'dog',
            phonetic: 'dɔːɡ',
            chinese: '狗'
          },
          {
            english: 'bird',
            phonetic: 'bɜːd',
            chinese: '鸟'
          },
          {
            english: 'fish',
            phonetic: 'fɪʃ',
            chinese: '鱼'
          },
          {
            english: 'rabbit',
            phonetic: 'ˈræbɪt',
            chinese: '兔子'
          }
        ]
      },
      // 第三组
      {
        groupName: '颜色类',
        words: [
          {
            english: 'red',
            phonetic: 'red',
            chinese: '红色'
          },
          {
            english: 'blue',
            phonetic: 'bluː',
            chinese: '蓝色'
          },
          {
            english: 'green',
            phonetic: 'ɡriːn',
            chinese: '绿色'
          },
          {
            english: 'yellow',
            phonetic: 'ˈjeloʊ',
            chinese: '黄色'
          },
          {
            english: 'black',
            phonetic: 'blæk',
            chinese: '黑色'
          }
        ]
      },
      // 第四组
      {
        groupName: '数字类',
        words: [
          {
            english: 'one',
            phonetic: 'wʌn',
            chinese: '一'
          },
          {
            english: 'two',
            phonetic: 'tuː',
            chinese: '二'
          },
          {
            english: 'three',
            phonetic: 'θriː',
            chinese: '三'
          },
          {
            english: 'four',
            phonetic: 'fɔːr',
            chinese: '四'
          },
          {
            english: 'five',
            phonetic: 'faɪv',
            chinese: '五'
          }
        ]
      },
      // 第五组
      {
        groupName: '家庭类',
        words: [
          {
            english: 'mother',
            phonetic: 'ˈmʌðər',
            chinese: '妈妈'
          },
          {
            english: 'father',
            phonetic: 'ˈfɑːðər',
            chinese: '爸爸'
          },
          {
            english: 'sister',
            phonetic: 'ˈsɪstər',
            chinese: '姐妹'
          },
          {
            english: 'brother',
            phonetic: 'ˈbrʌðər',
            chinese: '兄弟'
          },
          {
            english: 'baby',
            phonetic: 'ˈbeɪbi',
            chinese: '婴儿'
          }
        ]
      },
      // 第六组
      {
        groupName: '食物类',
        words: [
          {
            english: 'bread',
            phonetic: 'bred',
            chinese: '面包'
          },
          {
            english: 'milk',
            phonetic: 'mɪlk',
            chinese: '牛奶'
          },
          {
            english: 'rice',
            phonetic: 'raɪs',
            chinese: '米饭'
          },
          {
            english: 'egg',
            phonetic: 'eɡ',
            chinese: '鸡蛋'
          },
          {
            english: 'meat',
            phonetic: 'miːt',
            chinese: '肉'
          }
        ]
      },
      // 第七组
      {
        groupName: '学校类',
        words: [
          {
            english: 'book',
            phonetic: 'bʊk',
            chinese: '书'
          },
          {
            english: 'pen',
            phonetic: 'pen',
            chinese: '钢笔'
          },
          {
            english: 'desk',
            phonetic: 'desk',
            chinese: '课桌'
          },
          {
            english: 'chair',
            phonetic: 'tʃer',
            chinese: '椅子'
          },
          {
            english: 'teacher',
            phonetic: 'ˈtiːtʃər',
            chinese: '老师'
          }
        ]
      },
      // 第八组
      {
        groupName: '天气类',
        words: [
          {
            english: 'sun',
            phonetic: 'sʌn',
            chinese: '太阳'
          },
          {
            english: 'rain',
            phonetic: 'reɪn',
            chinese: '雨'
          },
          {
            english: 'snow',
            phonetic: 'snoʊ',
            chinese: '雪'
          },
          {
            english: 'wind',
            phonetic: 'wɪnd',
            chinese: '风'
          },
          {
            english: 'cloud',
            phonetic: 'klaʊd',
            chinese: '云'
          }
        ]
      },
      // 第九组
      {
        groupName: '运动类',
        words: [
          {
            english: 'run',
            phonetic: 'rʌn',
            chinese: '跑步'
          },
          {
            english: 'jump',
            phonetic: 'dʒʌmp',
            chinese: '跳'
          },
          {
            english: 'swim',
            phonetic: 'swɪm',
            chinese: '游泳'
          },
          {
            english: 'walk',
            phonetic: 'wɔːk',
            chinese: '走路'
          },
          {
            english: 'dance',
            phonetic: 'dæns',
            chinese: '跳舞'
          }
        ]
      },
      // 第十组
      {
        groupName: '衣物类',
        words: [
          {
            english: 'shirt',
            phonetic: 'ʃɜːrt',
            chinese: '衬衫'
          },
          {
            english: 'pants',
            phonetic: 'pænts',
            chinese: '裤子'
          },
          {
            english: 'shoes',
            phonetic: 'ʃuːz',
            chinese: '鞋子'
          },
          {
            english: 'hat',
            phonetic: 'hæt',
            chinese: '帽子'
          },
          {
            english: 'sock',
            phonetic: 'sɑːk',
            chinese: '袜子'
          }
        ]
      }
    ],
    currentWord: {},
    currentExample: {},
    dictType: 'course', // 当前选中的词库类型：'course' 或 'cambridge'
    grade3Expanded: false,
    grade4Expanded: false,
    starterExpanded: false,
    level1Expanded: false,
    cambridgeWords: {
      starter: {
        semester1: {
          unit1: [
            { english: 'hello', chinese: '喂、你好', phonetic: 'həˈləʊ' },
            { english: 'monkey', chinese: '猴子、顽童', phonetic: 'ˈmʌŋki' },
            { english: 'panda', chinese: '大熊猫', phonetic: 'ˈpændə' },
            { english: 'Teddy bear', chinese: '玩具熊', phonetic: 'ˈtedi beə' }
          ],
          unit2: [
            { english: 'bear', chinese: '熊', phonetic: 'beə' },
            { english: 'apple', chinese: '苹果', phonetic: 'ˈæpl' },
            { english: 'banana', chinese: '香蕉', phonetic: 'bəˈnɑːnə' },
            { english: 'bamboo', chinese: '竹子', phonetic: 'bæmˈbuː' },
            { english: 'cake', chinese: '蛋糕', phonetic: 'keɪk' },
            { english: 'candy', chinese: '糖', phonetic: 'ˈkændi' }
          ],
          unit3: [
            { english: 'dog', chinese: '狗', phonetic: 'dɒɡ' },
            { english: 'duck', chinese: '鸭子', phonetic: 'dʌk' },
            { english: 'eel', chinese: '鳝鱼，鳗鱼', phonetic: 'iːl' },
            { english: 'elephant', chinese: '大象', phonetic: 'ˈelɪfənt' },
            { english: 'fish', chinese: '鱼，鱼肉', phonetic: 'fɪʃ' },
            { english: 'giraffe', chinese: '长颈鹿', phonetic: 'dʒɪˈrɑːf' },
            { english: 'frog', chinese: '青蛙', phonetic: 'frɒɡ' },
            { english: 'girl', chinese: '女孩', phonetic: 'ɡɜːl' }
          ],
          unit4: [
            { english: 'house', chinese: '房子', phonetic: 'haʊs' },
            { english: 'horse', chinese: '马', phonetic: 'hɔːs' },
            { english: 'kite', chinese: '风筝', phonetic: 'kaɪt' },
            { english: 'jacket', chinese: '短上衣，夹克', phonetic: 'ˈdʒækɪt' },
            { english: 'ice', chinese: '冰', phonetic: 'aɪs' },
            { english: 'ice cream', chinese: '冰激凌', phonetic: 'aɪs kriːm' },
            { english: 'letter', chinese: '字母', phonetic: 'ˈletə' }
          ],
          unit5: [
            { english: 'lemon', chinese: '柠檬', phonetic: 'ˈlemən' },
            { english: 'lamp', chinese: '灯', phonetic: 'læmp' },
            { english: 'mango', chinese: '芒果', phonetic: 'ˈmæŋɡəʊ' },
            { english: 'nose', chinese: '鼻子', phonetic: 'nəʊz' },
            { english: 'watermelon', chinese: '西瓜', phonetic: 'ˈwɔːtəmelən' },
            { english: 'orange', chinese: '橘子', phonetic: 'ˈɒrɪndʒ' },
            { english: 'pineapple', chinese: '菠萝', phonetic: 'ˈpaɪnæpl' }
          ],
          unit6: [
            { english: 'orange', chinese: '橘子；橙；橙色', phonetic: 'ˈɒrɪndʒ' },
            { english: 'pineapple', chinese: '菠萝', phonetic: 'ˈpaɪnæpl' },
            { english: 'queen', chinese: '王后，女王', phonetic: 'kwiːn' }
          ],
          unit7: [
            { english: 'rabbit', chinese: '兔子', phonetic: 'ˈræbɪt' },
            { english: 'snake', chinese: '蛇', phonetic: 'sneɪk' },
            { english: 'turtle', chinese: '海龟', phonetic: 'ˈtɜːtl' },
            { english: 'ruler', chinese: '尺子', phonetic: 'ˈruːlə' },
            { english: 'sun', chinese: '太阳', phonetic: 'sʌn' },
            { english: 'tea', chinese: '茶', phonetic: 'tiː' }
          ],
          unit8: [
            { english: 'umbrella', chinese: '傘、雨傘', phonetic: 'ʌmˈbrelə' },
            { english: 'vest', chinese: '背心', phonetic: 'vest' },
            { english: 'window', chinese: '窗，窗户', phonetic: 'ˈwɪndəʊ' },
            { english: 'ant', chinese: '蚂蚁', phonetic: 'ænt' },
            { english: 'bee', chinese: '蜜蜂', phonetic: 'biː' },
            { english: 'kangaroo', chinese: '袋鼠', phonetic: 'ˌkæŋɡəˈruː' },
            { english: 'juice', chinese: '果汁', phonetic: 'dʒuːs' }
          ],
          unit9: [
            { english: 'fox', chinese: '狐狸', phonetic: 'fɒks' },
            { english: 'yo-yo', chinese: '悠悠球', phonetic: 'ˈjəʊ jəʊ' },
            { english: 'zebra', chinese: '斑马', phonetic: 'ˈzebrə' },
            { english: 'brush', chinese: '刷子', phonetic: 'brʌʃ' },
            { english: 'pencil', chinese: '铅笔', phonetic: 'ˈpensl' },
            { english: 'paint', chinese: '油漆、涂料', phonetic: 'peɪnt' },
            { english: 'pen', chinese: '钢笔', phonetic: 'pen' },
            { english: 'blue', chinese: '蓝色', phonetic: 'bluː' },
            { english: 'yellow', chinese: '黄色', phonetic: 'ˈjeləʊ' },
            { english: 'green', chinese: '绿色', phonetic: 'ɡriːn' },
            { english: 'black', chinese: '黑色', phonetic: 'blæk' },
            { english: 'pink', chinese: '粉色', phonetic: 'pɪŋk' },
            { english: 'red', chinese: '红色', phonetic: 'red' }
          ],
          unit10: [
            { english: 'arm', chinese: '手臂', phonetic: 'ɑːm' },
            { english: 'ant', chinese: '蚂蚁', phonetic: 'ænt' },
            { english: 'bike', chinese: '自行车', phonetic: 'baɪk' },
            { english: 'book', chinese: '书，书籍', phonetic: 'bʊk' },
            { english: 'cap', chinese: '帽子', phonetic: 'kæp' },
            { english: 'cow', chinese: '奶牛', phonetic: 'kaʊ' },
            { english: 'desk', chinese: '书桌，课桌', phonetic: 'desk' },
            { english: 'door', chinese: '门', phonetic: 'dɔː' },
            { english: 'animal', chinese: '动物', phonetic: 'ˈænɪml' },
            { english: 'bus', chinese: '公共汽车', phonetic: 'bʌs' },
            { english: 'bird', chinese: '鸟，禽', phonetic: 'bɜːd' },
            { english: 'car', chinese: '汽车', phonetic: 'kɑː' },
            { english: 'game', chinese: '游戏', phonetic: 'ɡeɪm' },
            { english: 'play', chinese: '玩耍，游戏', phonetic: 'pleɪ' }
          ],
          unit11: [
            { english: 'glad', chinese: '高兴的', phonetic: 'ɡlæd' },
            { english: 'meet', chinese: '遇见，见面', phonetic: 'miːt' },
            { english: 'afternoon', chinese: '午后，下午', phonetic: 'ˌɑːftəˈnuːn' },
            { english: 'evening', chinese: '傍晚，晚间', phonetic: 'ˈiːvnɪŋ' }
          ],
          unit12: [
            { english: 'red', chinese: '红色，红色的', phonetic: 'red' },
            { english: 'black', chinese: '黑色，黑色的', phonetic: 'blæk' },
            { english: 'orange', chinese: '橙色，橙色的', phonetic: 'ˈɒrɪndʒ' },
            { english: 'white', chinese: '白色，白色的', phonetic: 'waɪt' },
            { english: 'flower', chinese: '花', phonetic: 'ˈflaʊə' },
            { english: 'sheep', chinese: '羊，绵羊', phonetic: 'ʃiːp' },
            { english: 'juice', chinese: '（水果）汁', phonetic: 'dʒuːs' }
          ],
          unit13: [
            { english: 'which', chinese: '哪个，哪几个', phonetic: 'wɪtʃ' },
            { english: 'where', chinese: '在哪里', phonetic: 'weə' },
            { english: 'classroom', chinese: '教室', phonetic: 'ˈklɑːsruːm' },
            { english: 'kindergarten', chinese: '幼儿园', phonetic: 'ˈkɪndəɡɑːtn' },
            { english: 'sea', chinese: '海，海洋', phonetic: 'siː' },
            { english: 'bookshop', chinese: '书店', phonetic: 'ˈbʊkʃɒp' },
            { english: 'park', chinese: '公园', phonetic: 'pɑːk' },
            { english: 'beach', chinese: '海滩', phonetic: 'biːtʃ' },
            { english: 'swimming pool', chinese: '游泳池', phonetic: 'ˈswɪmɪŋ puːl' },
            { english: 'street', chinese: '街，街道', phonetic: 'striːt' },
            { english: 'bus stop', chinese: '公共汽车站', phonetic: 'bʌs stɒp' },
            { english: 'shop', chinese: '商店', phonetic: 'ʃɒp' },
            { english: 'playground', chinese: '运动场，操场', phonetic: 'ˈpleɪɡraʊnd' },
            { english: 'farm', chinese: '农场', phonetic: 'fɑːm' },
            { english: 'garden', chinese: '花园', phonetic: 'ˈɡɑːdn' },
            { english: 'bus station', chinese: '公共汽车站', phonetic: 'bʌs ˈsteɪʃn' }
          ],
          unit14: [
            { english: 'one', chinese: '一', phonetic: 'wʌn' },
            { english: 'two', chinese: '二', phonetic: 'tuː' },
            { english: 'three', chinese: '三', phonetic: 'θriː' },
            { english: 'four', chinese: '四', phonetic: 'fɔː' },
            { english: 'five', chinese: '五', phonetic: 'faɪv' },
            { english: 'six', chinese: '六', phonetic: 'sɪks' },
            { english: 'seven', chinese: '七', phonetic: 'ˈsevn' },
            { english: 'eight', chinese: '八', phonetic: 'eɪt' },
            { english: 'nine', chinese: '九', phonetic: 'naɪn' },
            { english: 'ten', chinese: '十', phonetic: 'ten' },
            { english: 'lion', chinese: '狮子', phonetic: 'ˈlaɪən' },
            { english: 'crocodile', chinese: '鳄鱼', phonetic: 'ˈkrɒkədaɪl' }
          ],
          unit15: [
            { english: 'give', chinese: '给', phonetic: 'ɡɪv' },
            { english: 'another', chinese: '又一个，另一个', phonetic: 'əˈnʌðə' },
            { english: 'again', chinese: '又，再次', phonetic: 'əˈɡen' },
            { english: 'spider', chinese: '蜘蛛', phonetic: 'ˈspaɪdə' }
          ],
          unit16: [
            { english: 'happy', chinese: '快乐的，幸福的', phonetic: 'ˈhæpi' },
            { english: 'new', chinese: '新的', phonetic: 'njuː' },
            { english: 'year', chinese: '年', phonetic: 'jɪə' },
            { english: 'present', chinese: '礼物', phonetic: 'ˈpreznt' },
            { english: 'camera', chinese: '相机', phonetic: 'ˈkæmərə' },
            { english: 'mirror', chinese: '镜子', phonetic: 'ˈmɪrə' },
            { english: 'jacket', chinese: '夹克上衣', phonetic: 'ˈdʒækɪt' },
            { english: 'doll', chinese: '玩偶洋娃娃', phonetic: 'dɒl' },
            { english: 'watch', chinese: '表、手表', phonetic: 'wɒtʃ' },
            { english: 'carrot', chinese: '胡萝卜', phonetic: 'ˈkærət' }
          ]
        },
        semester2: {
          unit1: [
            { english: 'school', chinese: '学校', phonetic: 'skuːl' },
            { english: 'pencil-box', chinese: '铅笔盒', phonetic: 'ˈpensl bɒks' },
            { english: 'bag', chinese: '袋子；书包', phonetic: 'bæɡ' },
            { english: 'blackboard', chinese: '黑板', phonetic: 'ˈblækbɔːd' },
            { english: 'eraser', chinese: '橡皮', phonetic: 'ɪˈreɪzə' },
            { english: 'ruler', chinese: '尺，直尺', phonetic: 'ˈruːlə' },
            { english: 'book', chinese: '书，书籍', phonetic: 'bʊk' },
            { english: 'pen', chinese: '钢笔', phonetic: 'pen' },
            { english: 'pencil', chinese: '铅笔', phonetic: 'ˈpensl' },
            { english: 'pencil-case', chinese: '铅笔盒', phonetic: 'ˈpensl keɪs' },
            { english: 'big', chinese: '大的', phonetic: 'bɪɡ' },
            { english: 'small', chinese: '小的', phonetic: 'smɔːl' },
            { english: 'pool', chinese: '水池', phonetic: 'puːl' }
          ],
          unit2: [
            { english: 'Olympics', chinese: '奥林匹克运动会', phonetic: 'əˈlɪmpɪks' },
            { english: 'hop', chinese: '单脚跳', phonetic: 'hɒp' },
            { english: 'up', chinese: '向上', phonetic: 'ʌp' },
            { english: 'down', chinese: '向下', phonetic: 'daʊn' },
            { english: 'jump', chinese: '跳跃', phonetic: 'dʒʌmp' },
            { english: 'touch', chinese: '接触，触摸', phonetic: 'tʌtʃ' },
            { english: 'catch', chinese: '捕获，赶上', phonetic: 'kætʃ' },
            { english: 'paint', chinese: '绘画', phonetic: 'peɪnt' },
            { english: 'bounce', chinese: '反跳，弹起', phonetic: 'baʊns' },
            { english: 'count', chinese: '数，计算', phonetic: 'kaʊnt' },
            { english: 'draw', chinese: '画，绘制', phonetic: 'drɔː' },
            { english: 'kick', chinese: '踢', phonetic: 'kɪk' },
            { english: 'stop', chinese: '停止', phonetic: 'stɒp' },
            { english: 'football', chinese: '足球', phonetic: 'ˈfʊtbɔːl' },
            { english: 'badminton', chinese: '羽毛球', phonetic: 'ˈbædmɪntən' },
            { english: 'baseball', chinese: '棒球', phonetic: 'ˈbeɪsbɔːl' },
            { english: 'basketball', chinese: '篮球', phonetic: 'ˈbɑːskɪtbɔːl' }
          ],
          unit3: [
            { english: 'you', chinese: '你，你们', phonetic: 'juː' },
            { english: 'I', chinese: '我', phonetic: 'aɪ' },
            { english: 'he', chinese: '他', phonetic: 'hiː' },
            { english: 'she', chinese: '她', phonetic: 'ʃiː' },
            { english: 'we', chinese: '我们', phonetic: 'wiː' },
            { english: 'it', chinese: '它', phonetic: 'ɪt' },
            { english: 'they', chinese: '他们，它们', phonetic: 'ðeɪ' },
            { english: 'write', chinese: '写', phonetic: 'raɪt' },
            { english: 'talk', chinese: '谈话，讲', phonetic: 'tɔːk' },
            { english: 'dance', chinese: '跳舞', phonetic: 'dɑːns' },
            { english: 'skate', chinese: '滑冰', phonetic: 'skeɪt' },
            { english: 'sing', chinese: '唱', phonetic: 'sɪŋ' }
          ],
          unit4: [
            { english: 'mum', chinese: '妈妈', phonetic: 'mʌm' },
            { english: 'dad', chinese: '爸爸', phonetic: 'dæd' },
            { english: 'thanks', chinese: '感谢', phonetic: 'θæŋks' },
            { english: 'watch', chinese: '看', phonetic: 'wɒtʃ' },
            { english: 'TV', chinese: '电视', phonetic: 'ˌtiːˈviː' },
            { english: 'friend', chinese: '朋友', phonetic: 'frend' },
            { english: 'play with', chinese: '玩；摆弄', phonetic: 'pleɪ wɪð' },
            { english: 'welcome', chinese: '欢迎', phonetic: 'ˈwelkəm' },
            { english: 'come', chinese: '来，来（自）', phonetic: 'kʌm' },
            { english: 'toy', chinese: '玩具', phonetic: 'tɔɪ' }
          ],
          unit5: [
            { english: 'pet', chinese: '宠物', phonetic: 'pet' },
            { english: 'parrot', chinese: '鹦鹉', phonetic: 'ˈpærət' },
            { english: 'mouse', chinese: '鼠，耗子', phonetic: 'maʊs' },
            { english: 'spider', chinese: '蜘蛛', phonetic: 'ˈspaɪdə' },
            { english: 'pig', chinese: '猪', phonetic: 'pɪɡ' },
            { english: 'tell', chinese: '告诉', phonetic: 'tel' }
          ]
        }
      },
      level1: {
        semester1: {
          unit1: [
            { english: 'hello', chinese: '喂、你好', phonetic: 'həˈləʊ' },
            { english: 'monkey', chinese: '猴子、顽童', phonetic: 'ˈmʌŋki' },
            { english: 'panda', chinese: '大熊猫', phonetic: 'ˈpændə' },
            { english: 'Teddy bear', chinese: '玩具熊', phonetic: 'ˈtedi beə' }
          ],
          unit2: [
            { english: 'bear', chinese: '熊', phonetic: 'beə' },
            { english: 'apple', chinese: '苹果', phonetic: 'ˈæpl' },
            { english: 'banana', chinese: '香蕉', phonetic: 'bəˈnɑːnə' },
            { english: 'bamboo', chinese: '竹子', phonetic: 'bæmˈbuː' },
            { english: 'cake', chinese: '蛋糕', phonetic: 'keɪk' },
            { english: 'candy', chinese: '糖', phonetic: 'ˈkændi' }
          ],
          unit3: [
            { english: 'dog', chinese: '狗', phonetic: 'dɒɡ' },
            { english: 'duck', chinese: '鸭子', phonetic: 'dʌk' },
            { english: 'eel', chinese: '鳝鱼，鳗鱼', phonetic: 'iːl' },
            { english: 'elephant', chinese: '大象', phonetic: 'ˈelɪfənt' },
            { english: 'fish', chinese: '���，鱼肉', phonetic: 'fɪʃ' },
            { english: 'giraffe', chinese: '长颈鹿', phonetic: 'dʒɪˈrɑːf' },
            { english: 'frog', chinese: '青蛙', phonetic: 'frɒɡ' },
            { english: 'girl', chinese: '女孩', phonetic: 'ɡɜːl' }
          ],
          unit4: [
            { english: 'house', chinese: '房子', phonetic: 'haʊs' },
            { english: 'horse', chinese: '马', phonetic: 'hɔːs' },
            { english: 'kite', chinese: '风筝', phonetic: 'kaɪt' },
            { english: 'jacket', chinese: '短上衣，夹克', phonetic: 'ˈdʒækɪt' },
            { english: 'ice', chinese: '冰', phonetic: 'aɪs' },
            { english: 'ice cream', chinese: '冰激凌', phonetic: 'aɪs kriːm' },
            { english: 'letter', chinese: '字母', phonetic: 'ˈletə' }
          ],
          unit5: [
            { english: 'lemon', chinese: '柠檬', phonetic: 'ˈlemən' },
            { english: 'lamp', chinese: '灯', phonetic: 'læmp' },
            { english: 'mango', chinese: '芒果', phonetic: 'ˈmæŋɡəʊ' },
            { english: 'nose', chinese: '鼻子', phonetic: 'nəʊz' },
            { english: 'watermelon', chinese: '西瓜', phonetic: 'ˈwɔːtəmelən' },
            { english: 'orange', chinese: '橘子', phonetic: 'ˈɒrɪndʒ' },
            { english: 'pineapple', chinese: '菠萝', phonetic: 'ˈpaɪnæpl' }
          ],
          unit6: [
            { english: 'orange', chinese: '橘子；橙；橙色', phonetic: 'ˈɒrɪndʒ' },
            { english: 'pineapple', chinese: '菠萝', phonetic: 'ˈpaɪnæpl' },
            { english: 'queen', chinese: '王后，女王', phonetic: 'kwiːn' }
          ],
          unit7: [
            { english: 'rabbit', chinese: '兔子', phonetic: 'ˈræbɪt' },
            { english: 'snake', chinese: '蛇', phonetic: 'sneɪk' },
            { english: 'turtle', chinese: '海龟', phonetic: 'ˈtɜːtl' },
            { english: 'ruler', chinese: '尺子', phonetic: 'ˈruːlə' },
            { english: 'sun', chinese: '太阳', phonetic: 'sʌn' },
            { english: 'tea', chinese: '茶', phonetic: 'tiː' }
          ],
          unit8: [
            { english: 'umbrella', chinese: '傘、雨傘', phonetic: 'ʌmˈbrelə' },
            { english: 'vest', chinese: '背心', phonetic: 'vest' },
            { english: 'window', chinese: '窗，窗户', phonetic: 'ˈwɪndəʊ' },
            { english: 'ant', chinese: '蚂蚁', phonetic: 'ænt' },
            { english: 'bee', chinese: '蜜蜂', phonetic: 'biː' },
            { english: 'kangaroo', chinese: '袋鼠', phonetic: 'ˌkæŋɡəˈruː' },
            { english: 'juice', chinese: '果汁', phonetic: 'dʒuːs' }
          ],
          unit9: [
            { english: 'fox', chinese: '狐狸', phonetic: 'fɒks' },
            { english: 'yo-yo', chinese: '悠悠球', phonetic: 'ˈjəʊ jəʊ' },
            { english: 'zebra', chinese: '斑马', phonetic: 'ˈzebrə' },
            { english: 'brush', chinese: '刷子', phonetic: 'brʌʃ' },
            { english: 'pencil', chinese: '铅笔', phonetic: 'ˈpensl' },
            { english: 'paint', chinese: '油漆、涂料', phonetic: 'peɪnt' },
            { english: 'pen', chinese: '钢笔', phonetic: 'pen' },
            { english: 'blue', chinese: '蓝色', phonetic: 'bluː' },
            { english: 'yellow', chinese: '黄色', phonetic: 'ˈjeləʊ' },
            { english: 'green', chinese: '绿色', phonetic: 'ɡriːn' },
            { english: 'black', chinese: '黑色', phonetic: 'blæk' },
            { english: 'pink', chinese: '粉色', phonetic: 'pɪŋk' },
            { english: 'red', chinese: '红色', phonetic: 'red' }
          ],
          unit10: [
            { english: 'arm', chinese: '手臂', phonetic: 'ɑːm' },
            { english: 'ant', chinese: '蚂蚁', phonetic: 'ænt' },
            { english: 'bike', chinese: '自行车', phonetic: 'baɪk' },
            { english: 'book', chinese: '书，书籍', phonetic: 'bʊk' },
            { english: 'cap', chinese: '帽子', phonetic: 'kæp' },
            { english: 'cow', chinese: '奶牛', phonetic: 'kaʊ' },
            { english: 'desk', chinese: '书桌，课桌', phonetic: 'desk' },
            { english: 'door', chinese: '门', phonetic: 'dɔː' },
            { english: 'animal', chinese: '动物', phonetic: 'ˈænɪml' },
            { english: 'bus', chinese: '公共汽车', phonetic: 'bʌs' },
            { english: 'bird', chinese: '鸟，禽', phonetic: 'bɜːd' },
            { english: 'car', chinese: '汽车', phonetic: 'kɑː' },
            { english: 'game', chinese: '游戏', phonetic: 'ɡeɪm' },
            { english: 'play', chinese: '玩耍，游戏', phonetic: 'pleɪ' }
          ],
          unit11: [
            { english: 'glad', chinese: '高兴的', phonetic: 'ɡlæd' },
            { english: 'meet', chinese: '遇见，见面', phonetic: 'miːt' },
            { english: 'afternoon', chinese: '午后，下午', phonetic: 'ˌɑːftəˈnuːn' },
            { english: 'evening', chinese: '傍晚，晚间', phonetic: 'ˈiːvnɪŋ' }
          ],
          unit12: [
            { english: 'red', chinese: '红色，红色的', phonetic: 'red' },
            { english: 'black', chinese: '黑色，黑色的', phonetic: 'blæk' },
            { english: 'orange', chinese: '橙色，橙色的', phonetic: 'ˈɒrɪndʒ' },
            { english: 'white', chinese: '白色，白色的', phonetic: 'waɪt' },
            { english: 'flower', chinese: '花', phonetic: 'ˈflaʊə' },
            { english: 'sheep', chinese: '羊，绵羊', phonetic: 'ʃiːp' },
            { english: 'juice', chinese: '（水果）汁', phonetic: 'dʒuːs' }
          ],
          unit13: [
            { english: 'which', chinese: '哪个，哪几个', phonetic: 'wɪtʃ' },
            { english: 'where', chinese: '在哪里', phonetic: 'weə' },
            { english: 'classroom', chinese: '教室', phonetic: 'ˈklɑːsruːm' },
            { english: 'kindergarten', chinese: '幼儿园', phonetic: 'ˈkɪndəɡɑːtn' },
            { english: 'sea', chinese: '海，海洋', phonetic: 'siː' },
            { english: 'bookshop', chinese: '书店', phonetic: 'ˈbʊkʃɒp' },
            { english: 'park', chinese: '公园', phonetic: 'pɑːk' },
            { english: 'beach', chinese: '海滩', phonetic: 'biːtʃ' },
            { english: 'swimming pool', chinese: '游泳池', phonetic: 'ˈswɪmɪŋ puːl' },
            { english: 'street', chinese: '街，街道', phonetic: 'striːt' },
            { english: 'bus stop', chinese: '公共汽车站', phonetic: 'bʌs stɒp' },
            { english: 'shop', chinese: '商店', phonetic: 'ʃɒp' },
            { english: 'playground', chinese: '运动场，操场', phonetic: 'ˈpleɪɡraʊnd' },
            { english: 'farm', chinese: '农场', phonetic: 'fɑːm' },
            { english: 'garden', chinese: '花园', phonetic: 'ˈɡɑːdn' },
            { english: 'bus station', chinese: '公共汽车站', phonetic: 'bʌs ˈsteɪʃn' }
          ],
          unit14: [
            { english: 'one', chinese: '一', phonetic: 'wʌn' },
            { english: 'two', chinese: '二', phonetic: 'tuː' },
            { english: 'three', chinese: '三', phonetic: 'θriː' },
            { english: 'four', chinese: '四', phonetic: 'fɔː' },
            { english: 'five', chinese: '五', phonetic: 'faɪv' },
            { english: 'six', chinese: '六', phonetic: 'sɪks' },
            { english: 'seven', chinese: '七', phonetic: 'ˈsevn' },
            { english: 'eight', chinese: '八', phonetic: 'eɪt' },
            { english: 'nine', chinese: '九', phonetic: 'naɪn' },
            { english: 'ten', chinese: '十', phonetic: 'ten' },
            { english: 'lion', chinese: '狮子', phonetic: 'ˈlaɪən' },
            { english: 'crocodile', chinese: '鳄鱼', phonetic: 'ˈkrɒkədaɪl' }
          ],
          unit15: [
            { english: 'give', chinese: '给', phonetic: 'ɡɪv' },
            { english: 'another', chinese: '又一个，另一个', phonetic: 'əˈnʌðə' },
            { english: 'again', chinese: '又，再次', phonetic: 'əˈɡen' },
            { english: 'spider', chinese: '蜘蛛', phonetic: 'ˈspaɪdə' }
          ],
          unit16: [
            { english: 'happy', chinese: '快乐的，幸福的', phonetic: 'ˈhæpi' },
            { english: 'new', chinese: '新的', phonetic: 'njuː' },
            { english: 'year', chinese: '年', phonetic: 'jɪə' },
            { english: 'present', chinese: '礼物', phonetic: 'ˈpreznt' },
            { english: 'camera', chinese: '相机', phonetic: 'ˈkæmərə' },
            { english: 'mirror', chinese: '镜子', phonetic: 'ˈmɪrə' },
            { english: 'jacket', chinese: '夹克上衣', phonetic: 'ˈdʒækɪt' },
            { english: 'doll', chinese: '玩偶洋娃娃', phonetic: 'dɒl' },
            { english: 'watch', chinese: '表、手表', phonetic: 'wɒtʃ' },
            { english: 'carrot', chinese: '胡萝卜', phonetic: 'ˈkærət' }
          ]
        }
      }
    }
  },

  // 创建音频上下文
  audioContext: null,

  onLoad() {
    // 初始化音频上下文
    this.audioContext = wx.createInnerAudioContext();
    // 初始化第一个单词
    const firstWord = this.data.wordGroups[0].words[0];
    this.setData({
      currentWord: firstWord,
      currentExample: {
        english: `I have ${firstWord.english === 'apple' ? 'an' : 'a'} ${firstWord.english}.`,
        chinese: `我有一个${firstWord.chinese}。`
      }
    });
  },

  setCurrentWord(groupIndex, wordIndex) {
    const word = this.data.wordGroups[groupIndex].words[wordIndex];

    // 为不同类型的单词设置不同的例句
    let example;
    switch (word.english) {
      // 水果类
      case 'apple':
        example = { english: 'I like red apples.', chinese: '我喜欢红苹果。' };
        break;
      case 'banana':
        example = { english: 'The monkey is eating a banana.', chinese: '猴子在吃香蕉。' };
        break;
      case 'orange':
        example = { english: 'This orange is very sweet.', chinese: '这个橙子很甜。' };
        break;
      case 'grape':
        example = { english: 'She bought some grapes.', chinese: '她买了一些葡萄。' };
        break;
      case 'peach':
        example = { english: 'The peach is juicy.', chinese: '这个桃子很多汁。' };
        break;

      // 动物类
      case 'cat':
        example = { english: 'The cat is sleeping on the bed.', chinese: '���在床上睡觉。' };
        break;
      case 'dog':
        example = { english: 'My dog likes to play with me.', chinese: '我的狗喜欢和我玩。' };
        break;
      case 'bird':
        example = { english: 'The bird is singing in the tree.', chinese: '鸟在树上唱歌。' };
        break;
      case 'fish':
        example = { english: 'There are many fish in the pond.', chinese: '池塘里有很多鱼。' };
        break;
      case 'rabbit':
        example = { english: 'The rabbit is eating a carrot.', chinese: '兔子在吃胡萝卜。' };
        break;

      // 颜色类
      case 'red':
        example = { english: 'I have a red shirt.', chinese: '我有一件红色的衬衫。' };
        break;
      case 'blue':
        example = { english: 'The sky is blue today.', chinese: '今天天空是蓝色的。' };
        break;
      case 'green':
        example = { english: 'I like green trees.', chinese: '我喜欢绿色的树。' };
        break;
      case 'yellow':
        example = { english: 'The sun is yellow.', chinese: '太阳是黄色的。' };
        break;
      case 'black':
        example = { english: 'She has black hair.', chinese: '她有黑色的头发。' };
        break;

      // 默认例句
      default:
        example = {
          english: `This is a ${word.english}.`,
          chinese: `这是一个${word.chinese}。`
        };
    }

    this.setData({
      currentGroup: groupIndex,
      currentWordIndex: wordIndex,
      currentWord: word,
      currentExample: example
    });
  },

  selectWord(e) {
    const { group, index } = e.currentTarget.dataset;
    this.setCurrentWord(group, index);
  },

  // 播放音频的通用方法
  playAudio(word, type = 1, rate = 1.0) {
    // 每次播放前重新创建音频上下文
    if (this.audioContext) {
      this.audioContext.destroy();
    }
    this.audioContext = wx.createInnerAudioContext();

    wx.showLoading({
      title: '加载中...',
    });

    // 有道词典发音API
    const audioSrc = `https://dict.youdao.com/dictvoice?audio=${word}&type=${type}`;
    this.audioContext.src = audioSrc;
    this.audioContext.playbackRate = rate;  // 设置播放速率

    this.audioContext.onCanplay(() => {
      wx.hideLoading();
      this.audioContext.play();
    });

    this.audioContext.onError(() => {
      wx.hideLoading();
      wx.showToast({
        title: '播放失败，请重试',
        icon: 'none'
      });
    });

    // 播放结束后释放资源
    this.audioContext.onEnded(() => {
      this.audioContext.destroy();
      this.audioContext = null;
    });
  },

  // 播���正常语速
  playNormal() {
    const word = this.data.currentWord.english;
    this.playAudio(word, 1);  // 英音男声，正常速度
  },

  // 播放慢速
  playSlow() {
    const word = this.data.currentWord.english;
    this.playAudio(word, 4, 0.8);  // 美音女声，0.8倍速
  },

  // 播放例句
  playExample() {
    const example = this.data.currentExample.english;

    // 每次播放前重新创建音频上下文
    if (this.audioContext) {
      this.audioContext.destroy();
    }
    this.audioContext = wx.createInnerAudioContext();

    wx.showLoading({
      title: '加载中...',
    });

    const audioSrc = `https://dict.youdao.com/dictvoice?audio=${encodeURIComponent(example)}&type=1`;
    this.audioContext.src = audioSrc;

    this.audioContext.onCanplay(() => {
      wx.hideLoading();
      this.audioContext.play();
    });

    this.audioContext.onError(() => {
      wx.hideLoading();
      wx.showToast({
        title: '播放失败，请重试',
        icon: 'none'
      });
    });

    // 播放结束后释放资源
    this.audioContext.onEnded(() => {
      this.audioContext.destroy();
      this.audioContext = null;
    });
  },

  prevGroup() {
    if (this.data.currentGroup > 0) {
      this.setCurrentWord(this.data.currentGroup - 1, 0);
    } else {
      wx.showToast({
        title: '已经是第一组了',
        icon: 'none'
      });
    }
  },

  nextGroup() {
    if (this.data.currentGroup < this.data.wordGroups.length - 1) {
      this.setCurrentWord(this.data.currentGroup + 1, 0);
    } else {
      wx.showToast({
        title: '已经是最后一组了',
        icon: 'none'
      });
    }
  },

  // 上一个单词
  prevWord() {
    const currentIndex = this.data.currentWordIndex;
    if (currentIndex > 0) {
      this.setCurrentWord(this.data.currentGroup, currentIndex - 1);
    } else {
      wx.showToast({
        title: '已经是第一个单词了',
        icon: 'none'
      });
    }
  },

  // 下一个单词
  nextWord() {
    const currentIndex = this.data.currentWordIndex;
    const currentGroup = this.data.wordGroups[this.data.currentGroup];
    if (currentIndex < currentGroup.words.length - 1) {
      this.setCurrentWord(this.data.currentGroup, currentIndex + 1);
    } else {
      wx.showToast({
        title: '已���是最后一个单词了',
        icon: 'none'
      });
    }
  },

  onUnload() {
    // 页面卸载时释放音频资源
    if (this.audioContext) {
      this.audioContext.destroy();
    }
  },

  // 切换词库类型
  switchDictType(e) {
    const type = e.currentTarget.dataset.type;
    this.setData({
      dictType: type,
      // 切换词库时折叠所有展开的列表
      grade3Expanded: false,
      grade4Expanded: false,
      starterExpanded: false,
      level1Expanded: false
    });
  },

  // 切换年级/级别的展开状态
  toggleGrade(e) {
    const grade = e.currentTarget.dataset.grade;
    const expandKey = `${grade}Expanded`;
    this.setData({
      [expandKey]: !this.data[expandKey]
    });
  },

  // 选择课程词库的课程
  selectLesson(e) {
    const { grade, lesson } = e.currentTarget.dataset;
    console.log(`选择了${grade === 'grade3' ? '三' : '四'}年级第${lesson}课`);
    // TODO: 加载对课程的单词数据
    this.loadLessonWords(grade, lesson);
  },

  // 生成随机例句 - 作为 Page 对象的方法
  generateRandomExample(word, chinese) {
    const templates = [
      {
        english: `I like ${word}.`,
        chinese: `我喜欢${chinese}。`
      },
      {
        english: `Look at the ${word}!`,
        chinese: `看这个${chinese}！`
      },
      {
        english: `Can you see the ${word}?`,
        chinese: `你能看到这个${chinese}吗？`
      },
      {
        english: `Where is the ${word}?`,
        chinese: `${chinese}在哪里？`
      },
      {
        english: `Do you have ${/^[aeiou]/i.test(word) ? 'an' : 'a'} ${word}?`,
        chinese: `你有${chinese}吗？`
      }
    ];
    return templates[Math.floor(Math.random() * templates.length)];
  },

  // 选择剑桥词库的单元
  selectUnit(e) {
    const { level, semester, unit } = e.currentTarget.dataset;
    const words = this.data.cambridgeWords[level][`semester${semester}`][`unit${unit}`];

    // 将单词数据转换为游戏所需格式
    const wordGroup = {
      groupName: `第${unit}单元`,
      words: words.map(word => {
        // 检查单词是否已经包含音标
        if (!word.phonetic) {
          console.warn(`单词 ${word.english} 缺少音标`);
        }

        // 随机例句模板
        const templates = [
          { english: `I like ${word.english}.`, chinese: `我喜欢${word.chinese}。` },
          { english: `Look at the ${word.english}!`, chinese: `看这个${word.chinese}！` },
          { english: `Can you see the ${word.english}?`, chinese: `你能看到这个${word.chinese}吗？` },
          { english: `Where is the ${word.english}?`, chinese: `${word.chinese}在哪里？` },
          { english: `Let's play with the ${word.english}.`, chinese: `让我们和${word.chinese}玩吧。` },
          { english: `I want to buy ${/^[aeiou]/i.test(word.english) ? 'an' : 'a'} ${word.english}.`, chinese: `我想买一个${word.chinese}。` },
          { english: `She likes the ${word.english} very much.`, chinese: `她非常喜欢这个${word.chinese}。` },
          { english: `Let's go to see the ${word.english}.`, chinese: `让我们去看看这个${word.chinese}。` },
          { english: `Do you have ${/^[aeiou]/i.test(word.english) ? 'an' : 'a'} ${word.english}?`, chinese: `你有${word.chinese}吗？` },
          { english: `My friend loves the ${word.english}.`, chinese: `我的朋友喜欢这个${word.chinese}。` },
          { english: `There are many ${word.english}s here.`, chinese: `这里有很多${word.chinese}。` },
          { english: `What a lovely ${word.english}!`, chinese: `多么可爱的${word.chinese}啊！` },
          { english: `I saw ${/^[aeiou]/i.test(word.english) ? 'an' : 'a'} ${word.english} yesterday.`, chinese: `我昨天看到了一个${word.chinese}。` },
          { english: `The ${word.english} is over there.`, chinese: `${word.chinese}在那边。` },
          { english: `We all love the ${word.english}.`, chinese: `我们都喜欢这个${word.chinese}。` }
        ];

        return {
          english: word.english,
          chinese: word.chinese,
          phonetic: word.phonetic || '',  // 确保即使没有音标也返回空字符串
          example: templates[Math.floor(Math.random() * templates.length)]
        };
      })
    };

    this.setData({
      wordGroups: [wordGroup],
      currentGroup: 0,
      currentWordIndex: 0
    }, () => {
      const firstWord = wordGroup.words[0];
      this.setData({
        currentWord: firstWord,
        currentExample: firstWord.example
      });
    });
  },

  // 加载课程词库的单词数据
  loadLessonWords(grade, lesson) {
    wx.showLoading({
      title: '加载中...'
    });

    // 模拟加载数据
    setTimeout(() => {
      wx.hideLoading();
      // 这里应该是实际的数据加载逻辑
      this.setData({
        currentGroup: 0,
        currentWordIndex: 0,
        // 加载新的单词组数据
        wordGroups: []  // 这里需要设置实际的单词数据
      });
    }, 500);
  },

  // 加载剑桥词库的单词数据
  loadUnitWords(level, semester, unit) {
    wx.showLoading({
      title: '加载中...'
    });

    // 模拟加载数据
    setTimeout(() => {
      wx.hideLoading();
      // 这里应该是���际的数据加载逻辑
      this.setData({
        currentGroup: 0,
        currentWordIndex: 0,
        // 加载新的单词组数据
        wordGroups: []  // 这里需要设置实际的单词数据
      });
    }, 500);
  }
}); 